import { ComputedRef } from 'vue';
/* model */
import { BaseSelectUserFormField, BaseSelectUserFormSelectFieldOption, BaseSelectUserFormStateFieldOption } from '@src/component/common/BaseSelectUser/components'
/* hooks */
import { useBaseSelectUserStoreLabelList, useBaseSelectUserStoreServiceProviderQualificationList, useBaseSelectUserStoreServiceProviderTypeList, useBaseSelectUserStoreStateList } from '@src/component/common/BaseSelectUser/store'
/* vue */
import { ref, computed } from 'vue'

import { t } from '@src/locales'

function useBaseSelectUserFilterFields() {
  
  const { userLabelList } = useBaseSelectUserStoreLabelList()
  const { userStateList } = useBaseSelectUserStoreStateList()
  const { serviceProviderTypeList } = useBaseSelectUserStoreServiceProviderTypeList()
  const { serviceProviderQualificationList } = useBaseSelectUserStoreServiceProviderQualificationList()
  
  const labelOptions: ComputedRef<BaseSelectUserFormSelectFieldOption[]> = computed(() => {
    return userLabelList.value.map(label => {
      return {
        label: label.name,
        value: String(label.id)
      }
    })
  })
  
  const stateOptions: ComputedRef<BaseSelectUserFormStateFieldOption[]> = computed(() => {
    return userStateList.value.map(state => {
      return {
        label: state.state,
        value: state.state,
        color: state.color
      }
    })
  })
  
  const serviceProviderTypeOptions: ComputedRef<BaseSelectUserFormSelectFieldOption[]> = computed(() => {
    return serviceProviderTypeList.value.map(type => {
      return {
        label: type,
        value: type
      }
    })
  })
  
  const serviceProviderQualificationOptions: ComputedRef<BaseSelectUserFormSelectFieldOption[]> = computed(() => {
    return serviceProviderQualificationList.value.map(qualification => {
      return {
        label: qualification,
        value: qualification
      }
    })
  })
  
  const departmentNameField = ref(
    new BaseSelectUserFormField(t('common.label.departmentName'), t('common.placeholder.inputKeyWordToSearch'))
  )
  
  const roleNameField = ref(
    new BaseSelectUserFormField(t('common.label.roleName'), t('common.placeholder.inputKeyWordToSearch'))
  )
  
  const stateField = ref(
    new BaseSelectUserFormField(t('common.label.workStatus'))
  )
  
  const labelField = ref(
    new BaseSelectUserFormField(t('common.label.memberTag'))
  )
  
  const serviceProviderTypeField = ref(
    new BaseSelectUserFormField(t('common.label.serviceProviderType'))
  )
  
  const serviceProviderQualificationField = ref(
    new BaseSelectUserFormField(t('common.label.serviceProviderQualification'))
  )
  
  const serviceProviderNameField = ref(
    new BaseSelectUserFormField(t('common.form.type.serviceProviderName'))
  )
  
  return {
    departmentNameField,
    roleNameField,
    stateField,
    labelField,
    serviceProviderTypeField,
    serviceProviderQualificationField,
    serviceProviderNameField,
    labelOptions,
    stateOptions,
    serviceProviderTypeOptions,
    serviceProviderQualificationOptions
  }
}

export {
  useBaseSelectUserFilterFields
}
